perf: eager-load params when streaming on cpu backend#1687
Merged
Conversation
Owner
|
I think it would be better to control this with a flag, such as |
df69b60 to
5f817c0
Compare
Contributor
Author
|
Done in 5f817c0. Switched to a public |
Owner
|
Thank you for your contribution. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
After #1644, model weights are loaded from disk lazily on the first
prepare_paramscall. For apps that pre-load the model (long-lived servers, batched generation) this means the actual disk I/O happens during the first sampling step rather than during the explicit model-load call. With--stream-layerson a large CPU-backed model, that first step pays the full multi-segment disk read while the host expects "the model is loaded, generation should be fast now."This PR adds an
--eager-loadflag (off by default). When set, all registered params are loaded into the params backend right after metadata validation, so subsequentprepare_paramscalls fast-path and the I/O cost is paid at model-load time instead of during sampling. No behavior change for users who don't pass the flag.Related
Follow-up to closed #1646 (same idea, was flag-named
--eager-load-params).Numbers
RTX 3060 12 GB,
--offload-to-cpu --stream-layers --max-vram -1:--eager-loadThe disk-read work isn't avoided, only relocated from "first sampling step" to "model load." For interactive / long-lived apps this is the user-visible win.
Checklist